package com.lagou.edu.course.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lagou.edu.course.dto.CourseDTO;
import com.lagou.edu.course.param.CourseQueryParam;
import com.lagou.edu.course.remote.CourseService;
import com.lagou.edu.reponse.ResponseDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 程  林
 * @date 2021-01-31 17:25
 * @description //
 * @since V1.0.0
 */
@RestController
@RequestMapping("/course")
public class BossCourseController {

    @Autowired
    private CourseService remoteCourseService;

    /**
     * @param courseQueryParam
     * @return
     */
    @PostMapping("/queryCourseList")
    public ResponseDTO queryCourseList(@RequestBody CourseQueryParam courseQueryParam) {

        Page<CourseDTO> page = remoteCourseService.queryCourseList(courseQueryParam);
        return ResponseDTO.success(page);
    }

    @PostMapping("/addOrUpdateCourse")
    ResponseDTO addOrUpdateCourse(@RequestBody CourseDTO courseDTO) {

        return ResponseDTO.success(remoteCourseService.addOrUpdateCourse(courseDTO));
    }

    @PostMapping("/updateCourseState")
    ResponseDTO updateCourseState(@RequestBody CourseDTO courseDTO) {

        return ResponseDTO.success(remoteCourseService.updateCourseState(courseDTO));
    }



}
